package com.bstek.bdf2.core.context;

import org.apache.commons.lang.StringUtils;

import com.bstek.dorado.core.Configure;
import com.bstek.dorado.core.io.ResourceLoader;
import com.bstek.dorado.core.pkgs.PackageConfigurer;

/**
 * core的包配置加载实现类
 * @author Jacky.gao
 * @since 2013年5月21日
 */
public class BDFDoradoContextLocationConfigurer implements PackageConfigurer {

	/**
	 * bdf4-core的一些核心配置注入
	 * @param resourceLoader
	 * @return
	 * @throws Exception
	 */
	@Override
	public String[] getPropertiesConfigLocations(ResourceLoader resourceLoader) throws Exception {
		String coreProperties="classpath:com/bstek/bdf2/core/config/bdf4-dorado.properties";
 		return new String[]{coreProperties};
	}

	/**
	 * 包路径下的上下文配置加入
	 * @param resourceLoader
	 * @return
	 * @throws Exception
	 */

	@Override
	public String[] getContextConfigLocations(ResourceLoader resourceLoader) throws Exception {
		String context="classpath:com/bstek/bdf2/core/config/bdf4-dorado-configs.xml";
 		String dataSourceContextLocation=Configure.getString("bdf2.dataSourceContextLocation");
		if(StringUtils.isNotEmpty(dataSourceContextLocation)){
			return new String[]{context,dataSourceContextLocation};
		}else{
			return new String[]{context};
		}
	}

	/**
	 * servlet上下文配置加入
	 * @param resourceLoader
	 * @return
	 * @throws Exception
	 */
	@Override
	public String[] getServletContextConfigLocations(ResourceLoader resourceLoader) throws Exception {
		return null;
	}
}
